home *** CD-ROM | disk | FTP | other *** search
- package sub_arctic.anim;
-
- /**
- * Implements the pacing function for a slow in slow out, ala the artkit
- * pacing function of the same name. This function has two transition
- * points, one for the end of the slow in and the other for the end
- * of the slow out. These must be symmetrical, i.e. if you supply
- * boundary value of 0.2 to the constructor the first 20% of the
- * time will be slow in and the last 20% will be in the slow_out.<p>
- *
- * @author Ian Smith
- */
- public class slow_in_slow_out implements pacer {
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Where to end the slow in, and where to begin the slow out (although
- * 1-_boundary is more correct for where to begin the slow out).
- */
- protected double _boundary;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * What is the amount of of time covered by the slow in and slow out?
- */
- protected double _val_at_boundary;
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Construct a slow in slow out pacer. <P>
- *
- * Providing the values 0.2 and 0.4 to this constructor would
- * cause the following to happen: <P>
- * <OL>
- * <LI> The first 40% of the actual time would be spent in the first 20%
- * of the transition (slow in)
- * <LI> The middle part of the transition would occur, and would occupy 20%
- * of the actual time
- * <LI> The final 40% of the actual time would be spent in the final 20% of
- * the transition
- * </OL>
- *
- * @param double bnd at what percent of the transition to end the slow in
- * and (symmetrically) at what point from the end of the
- * transition to begin the slow out.
- * @param double val the value of the pacing function at the end of the
- * slow-in (this is also symmetrical)
- */
- public slow_in_slow_out(double bnd, double val) {
-
- /* assign the values */
- _boundary=bnd;
- _val_at_boundary=val;
-
- /* validity check boundary */
- if (_boundary > 0.5) {
- _boundary = 0.5;
- } else {
- if (_boundary <= 0.0) {
- _boundary = 0.001;
- }
- }
-
- /* other validity check */
- if (_val_at_boundary < 0.0) {
- _val_at_boundary = 0.0;
- } else {
- if (_val_at_boundary > 1.0) {
- _val_at_boundary = 1.0;
- }
- }
-
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
-
- /**
- * Perform the transformation.
- * @param double t the value to transform (time value from 0.0 to 1.0)
- * @return double the transformed value under the slow-in-slow-out parameters
- */
- public double pace(double t) {
- /* leaving */
- if (t < _boundary) {
- return t*_val_at_boundary/_boundary;
- } else { /* arriving */
- if (t > 1.0-_boundary) {
- return (1-_val_at_boundary) +
- (t-(1-_boundary))*_val_at_boundary/_boundary;
- } else { /* normal */
- return _val_at_boundary +
- (t-_boundary)* (1-2*_val_at_boundary)/(1-2*_boundary);
- }
- }
- }
-
- /* . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . */
- }
-
- /*=========================== COPYRIGHT NOTICE ===========================
-
- This file is part of the subArctic user interface toolkit.
-
- Copyright (c) 1996 Scott Hudson and Ian Smith
- All rights reserved.
-
- The subArctic system is freely available for most uses under the terms
- and conditions described in
- http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html
- and appearing in full in the lib/interactor.java source file.
-
- The current release and additional information about this software can be
- found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
-
- ========================================================================*/
-